package com.example.palette.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;

import com.coder.ffmpeg.annotation.MediaAttribute;
import com.coder.ffmpeg.call.IFFmpegCallBack;
import com.coder.ffmpeg.jni.FFmpegCommand;
import com.coder.ffmpeg.utils.FFmpegUtils;
import com.example.palette.R;

import java.io.File;

public class ThirteenActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_thirteen);

    }
    long start= -1;
    public void decode(View view) {
        File src = new File(Environment.getExternalStorageDirectory(), "/one.mp4");
        File dest = new File(Environment.getExternalStorageDirectory(), "/two.avi");
        new Thread(){
            @Override
            public void run() {

                FFmpegCommand.runCmd(FFmpegUtils.transformAudio(src.getAbsolutePath(),dest.getAbsolutePath()), new IFFmpegCallBack() {
                    @Override
                    public void onStart() {
                        start = System.currentTimeMillis();
                    }

                    @Override
                    public void onProgress(int i, long l) {
                        Log.i("huachen---","正在转换i:"+i+" l:"+l);
                    }

                    @Override
                    public void onCancel() {

                    }

                    @Override
                    public void onComplete() {
                        long end = System.currentTimeMillis();
                        Log.i("huachen---","转换完毕"+(end-start));
                    }

                    @Override
                    public void onError(int i, String s) {

                    }
                });
            }
        }.start();
    }
}